<#escape x as x?html>
<div class="box box-solid box-fusion no-shadow no-border subList">
    <div class="box-header   hide">
        <div class="col-md-7">
            <h3 class="box-title">&nbsp;</h3>
        </div>
        <div class="box-tools">
            <@y.htmlFuzzySearchListForm>
                <input id="state" name="state" value="${state!}">
            </@y.htmlFuzzySearchListForm>
        </div>
    </div><!-- /.box-header -->
    <div class="box-body table-responsive no-padding">
        <table class="table table-inner-bordered table-hover with-border-top"
               data-form-name="应用">
            <thead>
            <th class="col-md-1 col-lg-1">
                应用
            </th>
            <th class="col-md-1 col-lg-1">
                申请用户
            </th>
            <th class="col-md-1 col-lg-1">
                状态
            </th>
            <th class="col-md-1 col-lg-1">
                申请时间
            </th>
            <th class="col-md-1 col-lg-1">
                审批时间
            </th>
            <th class="col-md-1 col-lg-1">
                审批意见
            </th>
            <th class="col-md-1 col-lg-1">
                操作
            </th>
            </thead>
            <tbody>
                <#if (page.entities??)&&(page.entities?size>0)>
                    <#list page.entities as record>
                    <tr record-id='${record.id}'>
                        <td>
                        ${(record.application.name)!''}
                        </td>
                        <td>
                        ${(record.user.name)!''}
                        </td>
                        <td>
                            <#if record.state=='APPLYING'>
                                <a type="button" class="btn btn-warning disabled" style="width: 80px;curosr:default;">待审批
                                </a><#elseif record.state=='SUCCESS'>
                            <a type="button" class="btn btn-success disabled" style="width: 80px;curosr:default;">审核通过<#else>
                                <a type="button" class="btn btn-danger disabled" style="width: 80px;curosr:default;">审核失败</a></#if>
                        </td>
                        <td>
                        ${(record.subscribeTime)!''}
                        </td>
                        <td>
                        ${(record.replyTime)!''}
                        </td>
                        <td>
                        ${(record.replyDesc)!''}
                        </td>
                        <td class="popup-close">
                            <#if record.state=='APPLYING'>
                                <button class="btn btn-default btn-sm sub-apply" value="${(record.application.id)!''}">
                                    <i class="fa fa-hand-paper-o">审批</i>
                                </button>
                            </#if>
                        </td>
                    </tr>
                    </#list>
                </#if>
            </tbody>
        </table>
    </div><!-- /.box-body -->
    <div class="box-footer no-border clearfix">
        <@y.htmlPaginationOverview/>
    </div>
</div><!-- /.box -->
    <@y.htmlModal type="apply" id="applyForm"/>
<script>
    context.call([
        "list",
        "tools",
        "core"
    ], function (list, tools, core) {

        list.initFuzzySearchList("/console/sub");
        function getRecordId() {
            return $(this).closest("[record-id]").attr("record-id");
        }

        $(".sub-apply").each(function () {
            $(this).on("click", function (e) {
                var id = getRecordId.call($(this));
                core.showApplyForm("#applyForm", {
                    formUrl: "/console/sub/approve?id=" + id,
                    postUrl: "/console/sub/subreply",
                    successUrl: "/console/sub",
                    formTitle: "订阅审批"
                });
            });
        });

    });

</script>
</#escape>